/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #e3f2fd 0%, #f1f8e9 100%);
    height: 100vh;
    overflow: hidden;
}

/* Container styles - responsive height for iframe vs full screen */
.container {
    width: 100%;
    height: 450px; /* Default iframe height */
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 8px;
    position: relative;
}

/* Full screen mode detection */
@media (min-height: 500px) {
    .container {
        height: 90vh;
    }
}

/* Control panel styles */
.control-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 12px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.enzyme-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.enzyme-status {
    font-weight: 600;
    font-size: 14px;
    color: #2e7d32;
    min-width: 100px;
}

/* Toggle switch styles */
.switch {
    position: relative;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #4caf50;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

/* Reset button styles */
.reset-btn {
    background: #ff7043;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.3s ease;
    min-height: 32px;
}

.reset-btn:hover {
    background: #f4511e;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 112, 67, 0.3);
}

.reset-btn:active {
    transform: translateY(0);
}

/* Main experiment area */
.experiment-area {
    flex: 1;
    display: flex;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    position: relative;
}

/* Ruler styles */
.ruler {
    width: 40px;
    background: linear-gradient(to bottom, #f5f5f5 0%, #e0e0e0 100%);
    border-right: 2px solid #666;
    position: relative;
    display: flex;
    flex-direction: column;
}

.ruler-marks {
    flex: 1;
    position: relative;
}

.ruler-label {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 10px;
    font-weight: 600;
    color: #666;
    padding: 8px 0;
    text-align: center;
    background: #e0e0e0;
}

/* Plant container */
.plant-container {
    flex: 1;
    position: relative;
    background: linear-gradient(to bottom, #87ceeb 0%, #98fb98 70%, #8b4513 100%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    overflow: hidden;
}

/* Soil base */
.soil {
    height: 60px;
    background: linear-gradient(to bottom, #8b4513 0%, #654321 100%);
    border-top: 3px solid #a0522d;
    position: relative;
}

.soil::before {
    content: '';
    position: absolute;
    top: -3px;
    left: 0;
    right: 0;
    height: 6px;
    background: repeating-linear-gradient(
        90deg,
        #90ee90 0px,
        #90ee90 3px,
        #7cfc00 3px,
        #7cfc00 6px
    );
}

/* Plant styles - Modified for natural movement */
.plant {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    /* Added subtle animation for natural movement */
    animation: naturalSway 4s ease-in-out infinite;
}

/* Natural swaying animation for the entire plant */
@keyframes naturalSway {
    0%, 100% { transform: translateX(-50%) rotate(0deg); }
    25% { transform: translateX(-50%) rotate(0.5deg); }
    50% { transform: translateX(-50%) rotate(0deg); }
    75% { transform: translateX(-50%) rotate(-0.5deg); }
}

/* Modified stem container for segmented, flexible growth */
.stem-container {
    position: relative;
    width: 6px;
    margin: 0 auto;
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Individual stem segments for natural bending */
.stem-segment {
    width: 6px;
    height: 10px;
    background: linear-gradient(to right, #2d5016 0%, #4a7c59 30%, #5d8b3a 50%, #4a7c59 70%, #2d5016 100%);
    border-radius: 3px;
    position: relative;
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 1px 0 2px rgba(0, 0, 0, 0.3), 0 0 3px rgba(0, 0, 0, 0.2);
    transform-origin: bottom center;
    /* Each segment has slight natural bend variations */
    animation: segmentSway 3s ease-in-out infinite;
}

/* Natural segment movement - each segment moves slightly differently */
@keyframes segmentSway {
    0%, 100% { transform: rotate(0deg); }
    33% { transform: rotate(var(--sway-angle, 0.3deg)); }
    66% { transform: rotate(calc(var(--sway-angle, 0.3deg) * -0.5)); }
}

/* Add texture lines to stem segments for more realistic look */
.stem-segment::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: 100%;
    background: linear-gradient(to bottom, transparent 0%, #2d5016 20%, #2d5016 80%, transparent 100%);
}

/* Leaves container - positioned relative to stem segments */
.leaves-container {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
}

/* Enhanced tomato leaf styles - more natural movement */
.leaf {
    position: absolute;
    width: 35px;
    height: 25px;
    background: transparent;
    transform-origin: bottom center;
    opacity: 0;
    animation: leafGrow 0.6s ease-out forwards, leafSway 3.5s ease-in-out infinite;
}

/* Natural leaf swaying animation */
@keyframes leafSway {
    0%, 100% { transform: scale(1) rotate(var(--rotation, 0deg)) translateY(0px); }
    25% { transform: scale(1) rotate(calc(var(--rotation, 0deg) + var(--leaf-sway, 2deg))) translateY(-1px); }
    50% { transform: scale(1) rotate(var(--rotation, 0deg)) translateY(0px); }
    75% { transform: scale(1) rotate(calc(var(--rotation, 0deg) - var(--leaf-sway, 1deg))) translateY(1px); }
}

/* Main leaflet of compound tomato leaf */
.leaf::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 20px;
    background: radial-gradient(ellipse at 30% 30%, #4CAF50 0%, #388E3C 60%, #2E7D32 100%);
    border-radius: 8px 8px 4px 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Side leaflets for compound leaf appearance */
.leaf::after {
    content: '';
    position: absolute;
    top: 8px;
    left: 2px;
    width: 10px;
    height: 12px;
    background: radial-gradient(ellipse at 30% 30%, #4CAF50 0%, #388E3C 60%, #2E7D32 100%);
    border-radius: 6px 6px 3px 3px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 
                22px 0 0 0 radial-gradient(ellipse at 30% 30%, #4CAF50 0%, #388E3C 60%, #2E7D32 100%);
}

/* Leaf stem (petiole) with natural flexibility */
.leaf-stem {
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 8px;
    background: #4a7c59;
    border-radius: 1px;
    animation: stemFlex 4s ease-in-out infinite;
}

/* Natural stem flexing animation */
@keyframes stemFlex {
    0%, 100% { transform: translateX(-50%) rotate(0deg); }
    50% { transform: translateX(-50%) rotate(var(--stem-flex, 1deg)); }
}

.leaf.left {
    left: -40px;
    transform: rotate(-25deg);
    --leaf-sway: 3deg;
    --stem-flex: 2deg;
}

.leaf.right {
    right: -40px;
    transform: rotate(25deg);
    --leaf-sway: -2deg;
    --stem-flex: -1.5deg;
}

@keyframes leafGrow {
    0% {
        opacity: 0;
        transform: scale(0) rotate(var(--rotation, 0deg));
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(var(--rotation, 0deg));
    }
}

/* Flowers container */
.flowers-container {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
}

/* Tomato flower styles - with natural movement */
.flower {
    position: absolute;
    width: 8px;
    height: 8px;
    background: radial-gradient(circle at center, #FFD54F 0%, #FFC107 70%, #FF8F00 100%);
    border-radius: 50%;
    opacity: 0;
    animation: flowerBloom 0.6s ease-out forwards, flowerSway 2.8s ease-in-out infinite;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Natural flower swaying */
@keyframes flowerSway {
    0%, 100% { transform: scale(1) translateY(0px); }
    50% { transform: scale(1) translateY(-0.5px); }
}

/* Flower petals using pseudo-elements */
.flower::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    width: 12px;
    height: 12px;
    background: radial-gradient(circle at center, #FFEB3B 0%, #FFC107 100%);
    border-radius: 50%;
    z-index: -1;
    opacity: 0.8;
}

/* Small center dot for flower */
.flower::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 2px;
    background: #8BC34A;
    border-radius: 50%;
}

@keyframes flowerBloom {
    0% {
        opacity: 0;
        transform: scale(0);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Enhanced tomato fruit styles - with natural hanging movement */
.fruit {
    position: absolute;
    width: 14px;
    height: 16px;
    background: radial-gradient(ellipse at 30% 25%, #FF6B6B 0%, #E53E3E 40%, #C53030 80%, #9C1A1A 100%);
    border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
    opacity: 0;
    animation: fruitGrow 0.8s ease-out forwards, fruitHang 3.2s ease-in-out infinite;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3), inset -2px -2px 4px rgba(0, 0, 0, 0.2);
    transform-origin: top center;
}

/* Natural fruit hanging and swaying animation */
@keyframes fruitHang {
    0%, 100% { transform: rotate(0deg) translateY(0px); }
    25% { transform: rotate(1deg) translateY(0.5px); }
    50% { transform: rotate(0deg) translateY(1px); }
    75% { transform: rotate(-0.5deg) translateY(0.5px); }
}

/* Tomato stem/calyx at top */
.fruit::before {
    content: '';
    position: absolute;
    top: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 4px;
    background: #4CAF50;
    border-radius: 50% 50% 0 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
}

/* Small highlight on tomato for glossy effect */
.fruit::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 4px;
    width: 4px;
    height: 6px;
    background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.6) 0%, transparent 70%);
    border-radius: 50%;
}

@keyframes fruitGrow {
    0% {
        opacity: 0;
        transform: scale(0);
        background: radial-gradient(ellipse at 30% 25%, #90EE90 0%, #66BB6A 40%, #4CAF50 80%, #388E3C 100%);
    }
    50% {
        background: radial-gradient(ellipse at 30% 25%, #FFB74D 0%, #FF9800 40%, #F57C00 80%, #E65100 100%);
    }
    100% {
        opacity: 1;
        transform: scale(1);
        background: radial-gradient(ellipse at 30% 25%, #FF6B6B 0%, #E53E3E 40%, #C53030 80%, #9C1A1A 100%);
    }
}

/* Height indicator */
.height-indicator {
    position: absolute;
    right: 10px;
    width: 30px;
    height: 2px;
    background: #ff4444;
    transition: bottom 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    bottom: 60px;
    box-shadow: 0 0 4px rgba(255, 68, 68, 0.5);
}

.height-indicator::before {
    content: '';
    position: absolute;
    right: 0;
    top: -3px;
    width: 0;
    height: 0;
    border-left: 6px solid #ff4444;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
}

/* Height display */
.height-display {
    position: absolute;
    right: 45px;
    background: rgba(255, 68, 68, 0.9);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    transition: bottom 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    bottom: 55px;
    backdrop-filter: blur(4px);
}

/* Information panel */
.info-panel {
    width: 200px;
    background: rgba(255, 255, 255, 0.95);
    padding: 12px;
    border-left: 1px solid #e0e0e0;
    overflow-y: auto;
}

.info-content p {
    font-size: 11px;
    line-height: 1.4;
    margin-bottom: 8px;
    color: #333;
}

.enzyme-explanation {
    background: rgba(76, 175, 80, 0.1);
    padding: 8px;
    border-radius: 6px;
    border-left: 3px solid #4caf50;
    font-style: italic;
}

/* Progress container */
.progress-container {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 12px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4caf50, #8bc34a);
    border-radius: 4px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    width: 0%;
}

.progress-label {
    font-size: 11px;
    font-weight: 600;
    color: #666;
    white-space: nowrap;
}

/* Responsive design for mobile */
@media (max-width: 768px) {
    .container {
        padding: 4px;
        gap: 4px;
    }
    
    .control-panel {
        padding: 6px 8px;
    }
    
    .enzyme-status {
        font-size: 12px;
        min-width: 80px;
    }
    
    .info-panel {
        width: 150px;
        padding: 8px;
    }
    
    .info-content p {
        font-size: 10px;
    }
    
    .reset-btn {
        padding: 6px 12px;
        font-size: 11px;
    }
}

/* Hover effects for interactivity */
.switch:hover .slider {
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.3);
}

.plant:hover {
    filter: brightness(1.1);
}

/* Animation for enzyme effect - modified for natural growth */
.enzyme-active .stem-container {
    animation: naturalGrow 0.8s ease-out;
}

@keyframes naturalGrow {
    0% { transform: scaleY(0.8) rotate(-1deg); }
    30% { transform: scaleY(1.05) rotate(0.5deg); }
    60% { transform: scaleY(0.98) rotate(-0.3deg); }
    100% { transform: scaleY(1) rotate(0deg); }
}